package com.frxuexi.reprot

import com.blankj.utilcode.util.GsonUtils
import com.frxuexi.lib_http.HttpType
import com.frxuexi.lib_http.NetWorkFactory
import com.frxuexi.reprot.entity.CommitReportData
import com.frxuexi.reprot.entity.ReportData
import com.frxuexi.reprot.entity.ReportEntity
import kotlinx.coroutines.flow.Flow
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody

class ReportRepository {
    val apiServiec by lazy { NetWorkFactory.factory(HttpType.NONE).create(ApiServiec::class.java) }

    fun getReport(map: Map<String,Int>):Flow<ReportData>{
        val json = GsonUtils.toJson(map)
        val body = RequestBody.create("application/json".toMediaTypeOrNull(), json)
        return apiServiec.getReport(body = body)
    }

    fun commitReport(map: Map<String,Any>):Flow<CommitReportData>{
        val json = GsonUtils.toJson(map)
        val body = RequestBody.create("application/json".toMediaTypeOrNull(), json)
        return apiServiec.commitReport(body = body)
    }
}